< previous page page_478 next page >

Page 478
e10a6a0a59f035e870d90cca05b85fce.gif
    Zmin = Zmin - Z
    Zmax = Zmax + Z

    ' Create the new grid object.
    Set TheGrid = New Grid3d
    TheGrid.SetBounds Xmin, Dx, NumX, Zmin, Dz, NumZ

    ' Fill in data values.
    X = Xmin
    For i = 1 To NumX
        Z = Zmin
        For j = 1 To NumZ
            ' Find close points to the upper left,
            ' upper right, lower left, and lower
            ' right. Average them.
            num_close = 1
            best_i(num_close) = NearestPoint( _
                X, Z, True, True)
            If best_i(num_close) > 0 Then _
                num_close = num_close + 1

            best_i(num_close) = NearestPoint( _
                X, Z, True, False)
            If best_i(num_close) > 0 Then _
                num_close = num_close + 1

            best_i(num_close) = NearestPoint( _
                X, Z, False, True)
            If best_i(num_close) > 0 Then _
                num_close = num_close + 1

            best_i(num_close) = NearestPoint( _
                X, Z, False, False)
            If best_i(num_close) > 0 Then _
                num_close = num_close + 1

            Y = WeightedAverage(X, Z, best_i, num_close - 1)

            ' Add the value to the grid.
            TheGrid.SetValue X, Y, Z
            Z = Z + Dz
        Next j
        X = X + Dx
    Next i
End Sub

' Return a weighted average for this point's value.
Private Function WeightedAverage(ByVal X As Single, _
    ByVal Z As Single, best_i() As Integer, _
    ByVal num As Integer) As Single
Dim i As Integer

 
< previous page page_478 next page >